
#region license
/// Copyright (c) 2007 Rodrigo B. de Oliveira, Jb Evain and the
/// individuals listed on the ChangeLog entries.
/// 
/// Permission is hereby granted, free of charge, to any person obtaining
/// a copy of this software and associated documentation files (the
/// "Software"), to deal in the Software without restriction, including
/// without limitation the rights to use, copy, modify, merge, publish,
/// distribute, sublicense, and/or sell copies of the Software, and to
/// permit persons to whom the Software is furnished to do so, subject to
/// the following conditions:
/// 
/// The above copyright notice and this permission notice shall be
/// included in all copies or substantial portions of the Software.
/// 
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
/// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
/// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
/// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
/// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
/// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
/// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#endregion
//
// DO NOT EDIT THIS FILE!
//
// This file was generated automatically by astgen.boo.
//

namespace Milo.Ast
{	
	using System.Collections;
	using System.Runtime.Serialization;
	
	[System.Serializable]
	public partial class MacroStatement : Statement
	{
		protected string _name;

		protected ExpressionCollection _arguments;

		protected Block _block;

	
		new public MacroStatement CloneNode()
		{
			return Clone() as MacroStatement;
		}
		override public NodeType NodeType
		{
			get
			{
				return NodeType.MacroStatement;
			}
		}
		
		override public void Accept(IAstVisitor visitor)
		{
			visitor.OnMacroStatement(this);
		}
		override public bool Matches(Node node)
		{	
			MacroStatement other = node as MacroStatement;
			if (null == other) return false;
			if (!Node.Matches(_modifier, other._modifier)) return NoMatch("MacroStatement._modifier");
			if (_name != other._name) return NoMatch("MacroStatement._name");
			if (!Node.AllMatch(_arguments, other._arguments)) return NoMatch("MacroStatement._arguments");
			if (!Node.Matches(_block, other._block)) return NoMatch("MacroStatement._block");
			return true;
		}
	
		override public bool Replace(Node existing, Node newNode)
		{
			if (base.Replace(existing, newNode))
			{
				return true;
			}
			if (_modifier == existing)
			{
				this.Modifier = (StatementModifier)newNode;
				return true;
			}
			if (_arguments != null)
			{
				Expression item = existing as Expression;
				if (null != item)
				{
					Expression newItem = (Expression)newNode;
					if (_arguments.Replace(item, newItem))
					{
						return true;
					}
				}
			}
			if (_block == existing)
			{
				this.Block = (Block)newNode;
				return true;
			}
			return false;
		}
		
		override public object Clone()
		{
			MacroStatement clone = (MacroStatement)FormatterServices.GetUninitializedObject(typeof(MacroStatement));
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
		
			if (null != _modifier)
			{
				clone._modifier = _modifier.Clone() as StatementModifier;
				clone._modifier.InitializeParent(clone);
			}
			clone._name = _name;
			if (null != _arguments)
			{
				clone._arguments = _arguments.Clone() as ExpressionCollection;
				clone._arguments.InitializeParent(clone);
			}
			if (null != _block)
			{
				clone._block = _block.Clone() as Block;
				clone._block.InitializeParent(clone);
			}
			return clone;
		}
	

		[System.Xml.Serialization.XmlAttribute]
		public string Name
		{
			get
			{

				return _name;
			}

			set
			{
				_name = value;
			}

		}
		

		[System.Xml.Serialization.XmlElement]
		public ExpressionCollection Arguments
		{
			get
			{

			if (_arguments == null) _arguments = new ExpressionCollection(this);

				return _arguments;
			}

			set
			{
				if (_arguments != value)
				{
					_arguments = value;
					if (null != _arguments)
					{
						_arguments.InitializeParent(this);
					}
				}
			}

		}
		

		[System.Xml.Serialization.XmlElement]
		public Block Block
		{
			get
			{
			if (_block == null)
			{
				_block = new Block();
				_block.InitializeParent(this);
			}

				return _block;
			}

			set
			{
				if (_block != value)
				{
					_block = value;
					if (null != _block)
					{
						_block.InitializeParent(this);
					}
				}
			}

		}
		

	}
}

